﻿
/*
Control Created by:Jezer Bautista
August 1, 2012
*/


$(document).ready(function () {



    //for modalDialog object access
    global.modal = {
        isActivated: false,
        Overlay: $('#modalOverlay'),
        Message: $('#modalMessage'),
        Title: $('#modalTitle span'),
        Close: $('#modalClose'),
        Content: $('#modalContent')
    };

    global.modalDialog = {

        refreshModal: function () {
            if ($(window).height() < $('body').height()) {
                global.modal.Overlay.css('height', $('body').height() + 'px');
            }
            else {
                global.modal.Overlay.css('height', $(window).height() + 'px');
            }
            global.modalDialog.updateTop();
        },
        showModal: function (title, message) {

            $("body").css("overflow", "hidden");
            $("body").css("overflow", "auto");

            global.modal.isActivated = true;
            global.modalDialog.updateTop();
            global.modal.Overlay.show();
            global.modal.Message.show();
            global.modal.Title.html(title);
            global.modal.Content.html(message);
            global.modalDialog.refreshModal();
        },
        hideModal: function () {
            //global.modalVisible = false;
            global.modal.Overlay.hide();
            global.modal.Message.hide();
        },

        assignClose: function () {
            global.modal.Close.bind('click', function () {
                global.modalDialog.hideModal();
            });
        },
        updateTop: function () {//update top location of message window dialog
            global.modal.Message.css('top', (($(window).height() / 2.5) + $(window).scrollTop()) + 'px');
        }

    };
    //assign the close button on the modal
    global.modalDialog.assignClose();

});
